package com.ruoyi.project.pandian.commit.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.pandian.commit.domain.PdCommitRecord;
import com.ruoyi.project.pandian.commit.service.IPdCommitRecordService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 盘点提交表Controller
 * 
 * @author ruoyi
 * @date 2023-04-14
 */
@Controller
@RequestMapping("/pandian/commit")
public class PdCommitRecordController extends BaseController
{
    private String prefix = "pandian/commit";

    @Autowired
    private IPdCommitRecordService pdCommitRecordService;

    @GetMapping()
    public String commit()
    {
        return prefix + "/commit";
    }

    /**
     * 查询盘点提交表列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PdCommitRecord pdCommitRecord)
    {
        startPage();
        List<PdCommitRecord> list = pdCommitRecordService.selectPdCommitRecordList(pdCommitRecord);
        return getDataTable(list);
    }

    /**
     * 导出盘点提交表列表
     */
    @Log(title = "盘点提交表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PdCommitRecord pdCommitRecord)
    {
        List<PdCommitRecord> list = pdCommitRecordService.selectPdCommitRecordList(pdCommitRecord);
        ExcelUtil<PdCommitRecord> util = new ExcelUtil<PdCommitRecord>(PdCommitRecord.class);
        return util.exportExcel(list, "盘点提交表数据");
    }

    /**
     * 新增盘点提交表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存盘点提交表
     */
    @Log(title = "盘点提交表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PdCommitRecord pdCommitRecord)
    {
        return toAjax(pdCommitRecordService.insertPdCommitRecord(pdCommitRecord));
    }

    /**
     * 修改盘点提交表
     */
    @GetMapping("/edit/{pdGuid}")
    public String edit(@PathVariable("pdGuid") String pdGuid, ModelMap mmap)
    {
        PdCommitRecord pdCommitRecord = pdCommitRecordService.selectPdCommitRecordByPdGuid(pdGuid);
        mmap.put("pdCommitRecord", pdCommitRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存盘点提交表
     */
    @Log(title = "盘点提交表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PdCommitRecord pdCommitRecord)
    {
        return toAjax(pdCommitRecordService.updatePdCommitRecord(pdCommitRecord));
    }

    /**
     * 删除盘点提交表
     */
    @Log(title = "盘点提交表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pdCommitRecordService.deletePdCommitRecordByPdGuids(ids));
    }
}
